﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BLL;
using BLL.Enums;
using DAL;

namespace ZsKateg.Controllers
{
    public class HomeController : Controller
    {
        private string connectionString;

        private FilmLogic filmLogic;
        private ChallengerLogic challengerLogic;

        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);
            
            connectionString = ConfigurationManager.ConnectionStrings["zskategDB"].ToString();

            if (filmLogic == null) filmLogic = new FilmLogic(connectionString);
            if (challengerLogic == null) challengerLogic = new ChallengerLogic(connectionString);
        }

        public ActionResult Index()
        {
            ViewData["MenuActive"] = (int)Menu.Bemutatkozas;

            return View();
        }
        #region Challenger

        public ActionResult Challengers()
        {
            ViewData["MenuActive"] = (int)Menu.Challengers;

            var model = challengerLogic.GetAllChallenger();

            return View(model);
        }

        public ActionResult ChallengerDetail(int id)
        {
            ViewData["MenuActive"] = (int)Menu.Challengers;

            var model = challengerLogic.GetChallenger(id);

            return View(model);
        }

        #endregion

        #region Challenge
        public ActionResult Challenges()
        {
            ViewData["MenuActive"] = (int)Menu.Challenges;

            var model = filmLogic.GetAllFilm();

            return View(model);
        }
        #endregion
    }
}
